/*
 * @Description: 
 * @Version: 1.0
 * @Autor: lairensi
 * @Date: 2021-08-26 16:53:20
 * @LastEditors: lairensi
 * @LastEditTime: 2021-08-31 13:29:55
 */
import 'package:flutter/material.dart';
import 'package:flutter_demo/config/index.dart';
import 'package:flutter_demo/provider/user_provider.dart';
import 'package:flutter_demo/route/jme_router.dart';
import 'package:flutter_demo/util/global.dart';
import 'package:provider/provider.dart';
import 'package:flutter_localizations/flutter_localizations.dart';


final JmeRouter router = JmeRouter();


void main() {
  Config.env = Env.DEV; // 开发环境
  runApp(MyApp());
}

class MyApp extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    return MultiProvider(
        //在MaterialApp外层嵌套一个MultiProvider
        providers: [
          /** 在这里面配置全局监听的类*/
          ChangeNotifierProvider.value(value:UserInfoProvider())
          // ChangeNotifierProvider(create: (context) => UserInfoProvider()),

        ],
        child: MaterialApp(
          navigatorKey:Global.navigatorKey,
          title: "Flutter Demo",
          // 默认路由
          initialRoute: '/',
          // 调用Routes.dart的路由方法
          onGenerateRoute: router.getRoutes,
          // 添加路由观察者
          // navigatorObservers: [routeObserver],
          debugShowCheckedModeBanner: false,
          localizationsDelegates: [
            //此处
            GlobalMaterialLocalizations.delegate,
            GlobalWidgetsLocalizations.delegate,
          ],
          supportedLocales: [
            //此处
            const Locale('zh', 'CH'),
            const Locale('en', 'US'),
          ],
          // 主题
          theme: ThemeData(
            //主题深色还是浅色
            brightness: Brightness.dark,
            // 导航颜色
            primaryColor: Color.fromRGBO(16, 16, 16, 1),
            // 自定义画布颜色
            canvasColor: Color.fromRGBO(24, 24, 24, 1),
            // 指定平台，应用特定平台控件风格
            platform: TargetPlatform.iOS,
          ),
        ));
  }
}
